import Vue from 'vue'
import VueRouter from 'vue-router'

import EmployeeLogin from '@/components/settings/EmployeeLogin'
import AdministratorLogin from '@/components/settings/AdministratorLogin'
import Home from '@/components/workbench/Home'
import Employee from '@/components/workbench/employee/Employee'
import Supplier from '@/components/workbench/goods_resource/Supplier'
import Warehouse from '@/components/workbench/goods_resource/Warehouse'
import MedicineType from '@/components/workbench/medicine/MedicineType'
import Medicine from '@/components/workbench/medicine/Medicine'
import Purchase from '@/components/workbench/procurement/Purchase'
import Procurement from '@/components/workbench/procurement/Procurement'
import Deliver from '@/components/workbench/deliver/Deliver'
import Inventory from '@/components/workbench/deliver/Inventory'
import Statistic from '@/components/workbench/statistic/Statistic'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/employeeLogin' },
  { path: '/employeeLogin', name: 'employeeLogin', component: EmployeeLogin },
  { path: '/administratorLogin', name: 'administratorLogin', component: AdministratorLogin },
  { 
    path: '/home',
    name: 'home', 
    component: Home,
    children:[
      { path: '/employee', name: 'employee', component: Employee },
      { path: '/supplier', name: 'supplier', component: Supplier },
      { path: '/warehouse', name: 'warehouse', component: Warehouse },
      { path: '/medicineType', name: 'medicineType', component: MedicineType },
      { path: '/medicine', name: 'medicine', component: Medicine },
      { path: '/purchase', name: 'purchase', component: Purchase },
      { path: '/procurement', name: 'procurement', component: Procurement },
      { path: '/deliver', name: 'deliver', component: Deliver },
      { path: '/inventory', name: 'inventory', component: Inventory },
      { path: '/statistic', name: 'statistic', component: Statistic },
    ]
  },
]

const router = new VueRouter({
  routes
})

export default router
